<cfsetting enablecfoutputonly="true">
<cfswitch expression="#thisTag.executionMode#">
	<cfcase value="start">
		<cfparam name="attributes.id" default="">
		<cfparam name="attributes.data" default="">
		<cfparam name="attributes.displayField" default="display">
		<cfparam name="attributes.valueField" default="value">
		<cfparam name="attributes.selected" default="">
		<cfparam name="attributes.label" default="">
		<cfparam name="attributes.labelClass" default="coopFieldLabel">
		<cfparam name="attributes.wrapElement" default="div">
		<cfparam name="attributes.delimiters" default=",">
		<cfparam name="attributes.formatter" type="string" default="">
		<cfparam name="attributes.formatterMask" type="string" default="">
		<cfparam name="attributes.formatterType" type="string" default="">
		<cfparam name="attributes.formatterVersion" type="string" default="">
		<cfif StructKeyExists(caller,'root')>
			<cfset root = caller.root>
		<cfelse>
			<cfset root = caller>
		</cfif>
		<cfif NOT thisTag.hasEndTag>
			<cfthrow detail="End tag required" message="All coop tags require an end tag." errorcode="sos.tag.attributes">
		</cfif>			
		<cfif attributes.id EQ ''>
			<cfthrow detail="Missing required attribute: 'id'" message="'id' attribute is required">
		</cfif>
		<cfif NOT structKeyExists(root,"coop")>
			<cfthrow detail="Missing required COOP object on calling page.">
		</cfif>
		<cfscript>
		standardattributes = 'id,formatter,formatterVersion,formatterMask,formatterType,data,displayField,wrapElement,valueField,selected,label,labelClass,delimiters';
		attributes = root.coop.mergeAttributes(attributes,root);
		attributeList = root.coop.createAttributeList(attributes,standardAttributes,root);
		</cfscript>
	</cfcase>
	<cfcase value="end">
			<cfscript>
			returnData = createObject("component","#root.coop.get_shareClassPath()#objects.coop.returnData").init(attributes.data,attributes.delimiters);
			recordCount = returnData.recordCount();
			resultString = '';
			for(iRow=1; iRow LTE recordCount; iRow = iRow + 1) {
				data = returnData.returnDataRowStruct(iRow);
				if (attributes.displayField EQ '')  {
					displayString = data[1];
				} else {
					if (reFindNoCase("##*##",attributes.displayField)) {
						displayString = evaluate(attributes.displayField);
					} else {
						displayString = data[attributes.displayField];
					}
				}
				if (len(attributes.formatter)) {
					displayString = root.coop._formatter(attributes.formatter,displayString,attributes);
				}
				if (attributes.valueField EQ '')  {
					valueString = data[1];
				} else {
					if (reFindNoCase("##*##",attributes.valueField)) {
						valueString = evaluate(attributes.valueField);
					} else {
						valueString = data[attributes.valueField];
					}
				}
				if (listFindNoCase(attributes.selected,valueString)) {
					resultString = listAppend(resultString,displayString); 	
				}				
			}
			resultString = '<#attributes.wrapElement# id="#attributes.id#"#attributeList#>#resultString#</#attributes.wrapElement#>';
			if (attributes.label NEQ '') {
				resultString = '<div class="#attributes.labelClass#">#attributes.label#</div>#resultString#';
			}
			writeOutput(resultString);
			
			</cfscript>
		</cfcase>
</cfswitch>
<cfsetting enablecfoutputonly="false">